#define _CRT_SECURE_NO_WARNINGS 1
#include"BinaryTree.h"
BTNode* root;
void BTNodeInitial(BTNode* root,BTDataType x)
{
	assert(root);
	root->data = x;
	root->left = NULL;
	root->right = NULL;
}
void Createdata()
{
	BTNode* n1 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n2 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n3 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n4 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n5 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n6 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n7 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n8 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n9 = (BTNode*)malloc(sizeof(BTNode));
	BTNode* n10 = (BTNode*)malloc(sizeof(BTNode));
	BTNodeInitial(n1, 1);
	BTNodeInitial(n2, 2);
	BTNodeInitial(n3, 3);
	BTNodeInitial(n4, 4);
	BTNodeInitial(n5, 5);
	BTNodeInitial(n6, 6);
	BTNodeInitial(n7, 7);
	BTNodeInitial(n8, 8);
	BTNodeInitial(n9, 9);
	BTNodeInitial(n10, 10);
	root = n1;
	n1->left = n2;
	n1->right = n3;
	n2->left = n4;
	n3->left = n5;
	n3->right = n6;
	n4->right = n7;
	n5->left = n8;
	n5->right = n9;
	n9->right = n10;
}
void Test1()
{
	BinaryTreePrevOrder(root);
	printf("\n");
	BinaryTreeInOrder(root);
	printf("\n");
	BinaryTreePostOrder(root);
	printf("\n");
	BinaryTreeLevelOrder(root);
	printf("\n");
}
void Test2()
{
	printf("%d\n",BinaryTreeSize(root));
	printf("%d\n", BinaryTreeLeafSize(root));
	printf("%d\n", BinaryTreeLevelKSize(root,4));     
	BTNode* tmp = BinaryTreeFind(root, 3);
	printf("%d ", tmp->data);
	tmp = BinaryTreeFind(root, 10);
	printf("%d ", tmp->data);
	tmp = BinaryTreeFind(root, 4);
	printf("%d ", tmp->data);
	tmp = BinaryTreeFind(root, 20);
	if (tmp == NULL)
	{
		printf("NULL\n");
	}
}
void Test3()
{
	BinaryTreePrevOrder(root);
	printf("\n");
	BTNode* tmp = root->left->left;
	printf("%d\n", tmp->data);
	BinaryTreeDestroy(root);
	root = NULL;
	printf("%d\n", tmp->data);
	tmp = NULL;
}
int main()
{
	//Createdata();
	//Test1();
	//Test2();
	//Test3();
	BTDataType str[20] = "abd###c##";
	int i = 0;
	BTNode* root = BinaryTreeCreate(str, &i);
	BinaryTreeLevelOrder(root);
	printf("%d\n", BinaryTreeComplete(root));
	return 0;
}